package com.es.hr.visitorscore;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import com.es.hr.emp.EmpBiz;
import com.es.util.common.CommonBiz;
import com.es.util.page.PageBean;
import com.es.util.page.PageNavigator;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class CtmListPopAction extends ActionSupport implements ServletRequestAware{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	HttpServletRequest request;
	 
	   public String execute()throws Exception
	   {
		   String queryName = request.getParameter("queryName")==null?"":request.getParameter("queryName");
		   String curpage = request.getParameter("curpage")==null?"1":request.getParameter("curpage");
		   String queryLogin = request.getParameter("queryLogin")==null?"":request.getParameter("queryLogin");
		   String emp_role = request.getParameter("emp_role")==null?"":request.getParameter("emp_role");
		   String emp_city_code = request.getParameter("emp_city_code")==null?"":request.getParameter("emp_city_code");
		   String emp_province_code = request.getParameter("emp_province_code")==null?"":request.getParameter("emp_province_code");
		   String emp_area_code = request.getParameter("emp_area_code")==null?"":request.getParameter("emp_area_code");
		   
//		   CommonBiz biz = new CommonBiz();
		   CommonBiz biz = null;
		   EmpBiz empBiz = new EmpBiz();
		   
		   //区域列表
		   request.setAttribute("areaList", biz.getAreaList());
		   //角色
		   request.setAttribute("roleList", biz.getCommonList("role"));
		   //省份列表
		   if(emp_area_code!=null)
			   request.setAttribute("provinceList", biz.getProvinceList(emp_area_code));
		   //城市列表
		   if(emp_province_code!=null)
			   request.setAttribute("cityList", biz.getCityList(emp_province_code));
		   
		   PageNavigator pageNav = new PageNavigator();	
		   if(!curpage.equals(""))
			   pageNav.setCurpage(Integer.parseInt(curpage));
		   ArrayList<String> param = new ArrayList<String>();
		   param.add(emp_area_code);
		   param.add(emp_province_code);
		   param.add(emp_city_code);
		   param.add(queryLogin);
		   param.add(emp_role);
		   param.add(queryName);		   
		   PageBean pageBean  = empBiz.queryCtmListPop(pageNav, param);		   
		   request.setAttribute("pageBean", pageBean);
		   
		   request.setAttribute("queryName", queryName);
		   request.setAttribute("queryLogin", queryLogin);
		   request.setAttribute("emp_role", emp_role);
		   request.setAttribute("emp_city_code", emp_city_code);
		   request.setAttribute("emp_province_code", emp_province_code);
		   request.setAttribute("emp_area_code", emp_area_code);
		   
		   return "success";
	   }
	
	   public void setServletRequest(HttpServletRequest request) {
		     this.request = request;
		   }
}